"use strict";

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller, jwt } = app;
  const baseUrl = app.config.baseUrl;
  router.post(baseUrl + "/admin/login", controller.admin.adminLogin);
  router.post(baseUrl + "/admin/logout", controller.admin.adminLogout);

  // 标签
  router.resources("tags", baseUrl + "/tags", jwt, controller.tags);
  router.put(baseUrl + "/statusTags/:id", jwt, controller.tags.updateStatus);

  // 分类
  router.resources(
    "categories",
    baseUrl + "/categories",
    jwt,
    controller.categories
  );

  // 关于
  router.resources("about", baseUrl + "/about", jwt, controller.about);

  // 用户管理
  router.resources("user", baseUrl + "/user", jwt, controller.user);

  // 网页配置-首页配置
  router.resources(
    "home",
    baseUrl + "/config/home",
    jwt,
    controller.config.home
  );

  // 网页配置-Header/Footer配置
  router.resources("hf", baseUrl + "/config/hf", jwt, controller.config.hf);

  // 网页配置-侧栏配置-个人简介
  router.resources(
    "right_introduction",
    baseUrl + "/config/right/introduction",
    jwt,
    controller.config.right.introduction
  );

  // 网页配置-侧栏配置-广告设置
  router.resources(
    "right_ad",
    baseUrl + "/config/right/ad",
    jwt,
    controller.config.right.ad
  );

  // 网页配置-侧栏配置-推荐设置
  router.resources(
    "right_recommend",
    baseUrl + "/config/right/recommend",
    jwt,
    controller.config.right.recommend
  );

  router.post(baseUrl + "/admin/create", controller.admin.create);
  router.get(baseUrl + "/admin/list", controller.admin.list);
  router.delete(baseUrl + "/admin/remove/:id", controller.admin.remove);
  router.put(baseUrl + "/admin/update", controller.admin.update);
};
